let loginfun = (function () {
    let $userName = $('.userName'),
        $userPass = $('.userPass'),
        $submit = $('.submit');
        function handle(){
            $submit.click(function() {
                let account = $userName.val().trim(),
                    password = $userPass.val().trim();

                if(account === "" || password === ""){
                    alert('账号密码不能为空！')
                    return;
                }
                password = md5(password);
                axios.post('/user/login',{
                    account,
                    password
                }).then(result => {
                    if(parseInt(result.code) ===0){
                        alert('登录成功，即将跳转');
                        window.location.href ="index.html";
                        return;
                    }
                    alert('账号或密码不正确，请重新输入');
                })
            })
        }


    return {
        init(){
            handle();
        }
    }
})();
loginfun.init();